package com.hl.web;

import com.alibaba.fastjson.JSON;
import com.hl.dao.ShopDaoimpl;
import com.hl.pojo.PanghuShopGoods;
import com.hl.util.GeneralResult;
import com.hl.util.PageResult;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.List;

@WebServlet("/shop/getPanghuShopGoodsList")
public class ShopManage extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    //获取参数：pageNum=1&pageSize=10&keyword=&goodsStatus=&shopId=4156&startTime=&endTime=
        String pageNum = req.getParameter("pageNum");
        String pageSize = req.getParameter("pageSize");
        String keyword = req.getParameter("keyword");
        String goodsStatus = req.getParameter("goodsStatus");
        String shopId = req.getParameter("shopId");
        String startTime = req.getParameter("startTime");
        String endTime = req.getParameter("endTime");
        //调用sql，查询数据
        ShopDaoimpl dao = new ShopDaoimpl();
        List<PanghuShopGoods> list = null;
        list = dao.displayShopManage(pageNum,pageSize,keyword,goodsStatus,shopId,startTime,endTime);

        //设置返回前端的数据
        PageResult pageResult = new PageResult(list);
        GeneralResult result = new GeneralResult(200, "操作成功", pageResult);
        //将数据返回给前端
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().append(JSON.toJSONString(result));
    }
}
